
	/************************************************************************************************

		Validators
			a, a+, al
			b, d, e, o, o-, re, null
			class, interface
			i, i!0, i+, i++, I, I+, I++
			n, ns, n+, n++, N, N+, N++
			s, si, s+, sr, qid, w
			url

	************************************************************************************************/


	//-------------------------------------------------------------------------------
	jsl.validator("a", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isArray(v))													throw error("BadType"					, [ id, "Array" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("a+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isArray(v))													throw error("BadType"					, [ id, "Array" ])
		if(!v.length)																throw error("EmptyArray"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("al", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isArrayLike(v))											throw error("BadType"					, [ id, "array-like" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("al+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isArrayLike(v))											throw error("BadType"					, [ id, "array-like" ])
		if(!v.length)																throw error("EmptyArray"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("b", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isBoolean(v))												throw error("BadType"					, [ id , "boolean" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("class", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isClass(v))													throw error("BadType"					, [ id, "jsl.Class" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("d", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isDate(v))													throw error("BadType"					, [ id , "Date" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("e", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isError(v))													throw error("BadType"					, [ id, "Error" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("interface", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue"				, [ id ])
		if(!jsl.isInterface(v))											throw error("BadType"					, [ id, "jsl.Interface" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("i", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber"  , [ id ])
		if(!jsl.isInteger(v))												throw error("NotInteger"			, [ id ])

		var n0, n1, le, ge

		if(params) {
			n0 = params[0] ? +params[0] : -Infinity
			n1 = params[1] ? +params[1] : +Infinity
			le = rule.indexOf("[") !== -1
			ge = rule.indexOf("]") !== -1

			if(params.length > 2)											throw error("BadValue"				, [ id ])
			if(isNaN(n0))															throw error("BadValue"				, [ id ])
			if(isNaN(n1))															throw error("BadValue"				, [ id ])
			if(params.length === 2 && n0 > n1)				throw error("BadValue"				, [ id ])

			if(le ? v < n0 : v <= n0)									throw error("BadValue"				, [ id ])
			if(ge	? v > n1 : v >= n1)									throw error("BadValue"				, [ id ])
		}
	})
	//-------------------------------------------------------------------------------
	jsl.validator("i!0", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber"  , [ id ])
		if(!jsl.isInteger(v))												throw error("NotInteger"			, [ id ])
		if(v == 0)																	throw error("BadValue"				, [ id, id + " != 0" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("i+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber"  , [ id ])
		if(v < 0)																		throw error("NegativeNumber"	, [ id ])
		if(!jsl.isInteger(v))												throw error("NotInteger"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("i++", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber" 	, [ id ])
		if(v <= 0)																	throw error("BadValue"				, [ id, id + " > 0" ])
		if(!jsl.isInteger(v))												throw error("NotInteger"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("I", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(isFinite(v) && !jsl.isInteger(v))				throw error("NotInteger"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("I+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(v < 0)																		throw error("NegativeNumber"	, [ id ])
		if(isFinite(v) && !jsl.isInteger(v))				throw error("NotInteger"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("I++", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(v <= 0)																	throw error("BadValue"				, [ id, id + " > 0" ])
		if(isFinite(v) && !jsl.isInteger(v))				throw error("NotInteger"			, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("f", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isFunction(v))											throw error("BadType" 				, [ id, "function" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("n", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber" 	, [ id ])

		var n0, n1, le, ge

		if(params) {
			n0 = params[0] ? +params[0] : -Infinity
			n1 = params[1] ? +params[1] : +Infinity
			le = rule.indexOf("[") !== -1
			ge = rule.indexOf("]") !== -1

			if(params.length > 2)											throw error("BadValue"				, [ id ])
			if(isNaN(n0))															throw error("BadValue"				, [ id ])
			if(isNaN(n1))															throw error("BadValue"				, [ id ])
			if(params.length === 2 && n0 > n1)				throw error("BadValue"				, [ id ])

			if(le ? v < n0 : v <= n0)									throw error("BadValue"				, [ id ])
			if(ge	? v > n1 : v >= n1)									throw error("BadValue"				, [ id ])
		}
	})
	//-------------------------------------------------------------------------------
	jsl.validator("ns", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])

		for(var a = 0, l = params.length; a < l; a++) {
			if(isNaN(+params[a]))	throw error("BadValidatorParams:ns")
			if(v == +params[a])	break
		}

		if(a === l) throw error("BadValue", [ id, params.join(", ") ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("null", function(v, rule, id, error, params) {
		if(v !== null && v !== undefined)	throw error("BadValue", [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("n+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber" 	, [ id ])
		if(v < 0)																		throw error("NegativeNumber"	, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("n++", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(!isFinite(v))														throw error("InfiniteNumber" 	, [ id ])
		if(v <= 0)																	throw error("BadValue"				, [ id, id + " > 0" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("N", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("N+", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(v < 0)																		throw error("NegativeNumber"	, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("N++", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isNumber(v))												throw error("BadType" 				, [ id, "number" ])
		if(isNaN(v))																throw error("NaNValue" 				, [ id ])
		if(v <= 0)																	throw error("BadValue"				, [ id, id + " > 0" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("o", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isObject(v))												throw error("BadType" 				, [ id, "object" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("o-", function(v, rule, id, error) {
		if(v != null && !jsl.isObject(v))						throw error("BadType" 				, [ id, "object" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("qid", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType" 				, [ id, "string" ])
		if(!v.length)																throw error("EmptyString"			, [ id ])
		if(!jsl.__re.qid.test(v)) 									throw error("BadQid"					, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("re", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isRegExp(v))												throw error("BadType" 				, [ id, "RegExp" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("url", function(v, rule, id, error) {
			if(v == null)																throw error("NullValue" 			, [ id ])
			if(!jsl.Url.valid(v)) 											throw error("BadUrl"					, [ id, v ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("s", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType" 				, [ id, "string" ])
		if(params && !jsl.Object.isIn(v, params))		throw error("BadValue"				, [ id, "[" + params.join(", ") + "]" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("si", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType" 				, [ id, "string" ])

		v = v.toLowerCase()
		for(var a = 0, l = params.length; a < l; a++)
			if(v === params[a].toLowerCase())
				break

		if(a === l)	throw error("BadValue", [ id, "[" + params.join(", ") + "]" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("s+", function(v, rule, id, error, params) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType" 				, [ id, "string" ])
		if(!v.length)																throw error("EmptyString"			, [ id ])
		if(params && !jsl.Object.isIn(v, params))		throw error("BadValue"				, [ id, "[" + params.join(", ") + "]" ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("sr", function(v, rule, id, error, params) {
		var re, fs

		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType" 				, [ id, "string" ])

		re = rule.slice(3)
		if((fs = re.match(/\/([gim]{1,3})$/i)))
			re = re.replace(/\/[gim]{1,3}$/, "")

		if(fs 	&& !RegExp(re, fs[1]).test(v))			throw error("BadValue" 				, [ id ])
		if(!fs 	&& !RegExp(re).test(v))							throw error("BadValue" 				, [ id ])
	})
	//-------------------------------------------------------------------------------
	jsl.validator("w", function(v, rule, id, error) {
		if(v == null)																throw error("NullValue" 			, [ id ])
		if(!jsl.isString(v))												throw error("BadType"					, [ id, "string" ])
		if(jsl.isString(v) 	&& !v.length)						throw error("EmptyString"			, [ id ])
		if(!(/^\w+$/).test(v))											throw error("BadValue"				, [ id ])
	})
	//composite
	//-------------------------------------------------------------------------------
	jsl.validator("t", function(v, rule, id, error, params) {
		var success

		if(v == null)	throw error("NullValue", [ id ])

		for(var a = 0, l = params.length; a < l && !success; a++)
			try 			{ jsl.validate(v, params[a], id); success = true 	}
			catch(e)	{}

		if(!success) throw error("BadType", [ id ])
	})
